<?php
/*
 * 手机客户端 秀场展品列表接口
 * 传入参数 
 * 2013-12-011
 */
include "inc/public_header.php";
include "func/user.php";				//用户信息处理函数

$hd_id			= $_REQUEST["hd_id"];			//活动主键

//获取用户信息
$uInfoArr = user_getInfoFromUUID();
if(!$uInfoArr){
	echo json_encode(array("success"=>"0","errCode"=>"0"));
	die;
}
$uid = $uInfoArr["uid"]; //用户信息主键
//$uid			= $_REQUEST["uid"];			//活动主键
$reJson = array();//构建返回值
 //$uid='10846';
$reJson["success"] = "1";

//作品总数
$sql = "select count(id) as ct from new_weituo_zuopin where dr='0' and uid='".$uid."' ";
if(isset($hd_id) && $hd_id!=""){
	$sql = $sql." and hd_id='".$hd_id."' ";
}
$db->query($sql);
$db->next_record();
$reJson["myWorks"] = $db->f("ct");

//获取赞作品总数量
$sql ="select count(0) as ct
		from 
				new_weituo_zuopin a	
				inner join new_weituo_pingfen b on a.id=b.zpid
		where
				a.dr='0'
				and a.aflag='1'
				and b.uid='".$uid."'
		";
if(isset($hd_id) && $hd_id!=""){
	$sql = $sql." and a.hd_id='".$hd_id."' ";
}
$db->query($sql);
$db->next_record();
$reJson["myPraise"] = $db->f("ct"); //设置作品总数量

//收藏作品总数
$sql = "select count(0) as ct from new_weituo_zuopin a inner join new_weituo_gz e on a.id=e.zpid where a.aflag='1' and a.dr='0' and e.uid='".$uid."'";
if(isset($hd_id) && $hd_id!=""){
	$sql = $sql." and a.hd_id='".$hd_id."' ";
}
$db->query($sql);
$db->next_record();
$reJson["myCollection"] = $db->f("ct");

//评论总数
$sql = "select count(0) as ct from new_weituo_comment a inner join new_weituo_zuopin b on a.zpid=b.id where b.dr='0' and a.dr='0' and b.aflag='1' and a.uid='".$uid."'";
if(isset($hd_id) && $hd_id!=""){
	$sql = $sql." and b.hd_id='".$hd_id."' ";
}
$db->query($sql);
$db->next_record();
$num1 = $db->f("ct");

//我的回复总数
$sql = "select 
				count(0) as ct 
			from 
				new_weituo_zuopin a 
				inner join new_weituo_huifu b on a.id=b.zpid
LEFT JOIN new_weituo_comment c on c.id=b.pid
		where 
			a.dr='0' and a.aflag='1' and b.dr='0' and c.dr='0' and b.uid='".$uid."' ";
if(isset($hd_id) && $hd_id!=""){
	$sql = $sql." and a.hd_id='".$hd_id."' ";
}
$db->query($sql);
$db->next_record();
$num2 = $db->f("ct");
$num=$num1+$num2;
$reJson["myCommentReplay"] =strval($num);

//关注人的总数
$sql = "select count(0) as ct from user_base a inner join new_weituo_fensi b on a.uid=b.fuid where b.fuid='".$uid."'";
if(isset($hd_id) && $hd_id!=""){
	$sql = $sql." and b.hd_id='".$hd_id."' ";
}
$db->query($sql);
$db->next_record();
$reJson["myAttention"] = $db->f("ct");

//获取粉丝总数
$sql = "select count(0) as ct from user_base a inner join new_weituo_fensi b on a.uid=b.uid where b.uid='".$uid."'";
if(isset($hd_id) && $hd_id!=""){
	$sql = $sql." and b.hd_id='".$hd_id."' ";
}
$db->query($sql);
$db->next_record();
$reJson["fans"] = $db->f("ct");
echo json_encode($reJson);
?>